﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using HienThi;

namespace GUI
{
    public partial class Form_ThongKeDonDatHang : UserControl
    {
        public Form_ThongKeDonDatHang()
        {
            InitializeComponent();
        }


        private void Form_ThongKeDonDatHang_Load(object sender, EventArgs e)
        {
            DateTime temp = DateTime.Now;
            txtThangNam.EditValue = temp.Month.ToString() + "/" + temp.Year.ToString(); 
        }

        private void btnTim_Click(object sender, EventArgs e)
        {
            ThongKeDDHBUS bus = new ThongKeDDHBUS();
            string[] thangnam = txtThangNam.EditValue.ToString().Split('/');
            int thang, nam;
            thang = int.Parse(thangnam[0]);
            nam = int.Parse(thangnam[1]);
            List<string> ds_maddh = bus.LayMaDDH(thang, nam);
            List<ThongKeDDHHienThi> grdcontrol = new List<ThongKeDDHHienThi>();
            for (int i = 0; i < ds_maddh.Count; i++)
            {
                ThongKeDDHHienThi temp = bus.LayBangThongKeDDHHienThi(ds_maddh[i], i + 1);
                grdcontrol.Add(temp);
            }
            grdcontrolThongKeDDH.DataSource = grdcontrol;
        }
    }
}
